package com.echo.im.domain.message.manager;

import com.echo.im.common.result.ResultEnum;
import com.echo.im.common.exception.GlobalException;
import com.echo.im.repository.dao.entity.GroupMessage;
import com.echo.im.repository.dao.mapper.GroupMessageMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @author: echo
 * @time: 2024-08-17
 */
@RequiredArgsConstructor
@Component
public class GroupMessageManager {

    private final GroupMessageMapper groupMessageMapper;

    public  GroupMessage getAndCheckByMsgId(Long messageId) {
        GroupMessage message = groupMessageMapper.selectById(messageId);
        if (Objects.isNull(message)) {
            throw new GlobalException(ResultEnum.NO_MESSAGE);
        }
        return message;
    }

}
